#!/usr/bin/env python
# -*- coding: utf8 -*-
# transmission 下载完成后运行的脚本
# TR_APP_VERSION
# TR_TIME_LOCALTIME
# TR_TORRENT_DIR
# TR_TORRENT_HASH
# TR_TORRENT_ID
# TR_TORRENT_NAME

import os, sys
def main()
    sys.stdout = open('/tmp/transmission.log', 'a')
    print 'torrent finished'
    if os.environ.get('TR_APP_VERSION'):
        try:
            torrent_dir = os.environ['TR_TORRENT_DIR']
            name = os.environ['TR_TORRENT_NAME']
            path = os.path.join(torrent_dir, name)
        except:
            return
        else:
            print path

if __name__ == '__main__':
    main()
